<?php

include '../../sql/conn.php';
if(empty($_REQUEST['step'])){
    $rs = mysql_query("select * from quotation where (noQuotation not like 'temp%')");
    $result = array();
    while($row = mysql_fetch_object($rs)){
            array_push($result, $row);
    }

    echo json_encode($result);
}
else {
    if($_REQUEST['step']=='2'){
        $idQuotation=$_REQUEST['id'];
        $rs_step2 = mysql_query("
                select b.*,a.*
                from barang a, quotation_item b
                where a.idBarang=b.idBarang and idQuotation = '$idQuotation'
                ");
        $result = array();
        while($row = mysql_fetch_object($rs_step2)){
                $test=$row->priceItem;
                if($test[0]=='t'){
                        $temp=explode('temp',$test);
                        $row->priceItem=$temp[1];
                }
                array_push($result, $row);
        }
        
        echo json_encode($result);
        
    }
}
?>
